package adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.hutoubenjg.R;

import java.util.List;

import bean.PaiXuBean;



/***
 * 示例adapter
 *
 * @author mr.w
 */
public class ZuJinAdapter extends android.widget.BaseAdapter {

    List<PaiXuBean> datas;
    int position;
    int layoutId;
    Activity context;

    public ZuJinAdapter(Activity context, List<PaiXuBean> datas, int layoutId) {
        this.context = context;
        this.datas = datas;
        this.layoutId = layoutId;
    }


    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(layoutId,null);
            holder.text= (TextView) convertView.findViewById(R.id.text);
            holder.is_select= (ImageView) convertView.findViewById(R.id.is_select);
            convertView.setTag(holder);

        }else{
            holder= (ViewHolder) convertView.getTag();
        }
        holder.text.setText(datas.get(position).getName());
        if(datas.get(position).isSelect()){
            holder.is_select.setVisibility(View.VISIBLE);
        }else{
            holder.is_select.setVisibility(View.GONE);
        }
        return convertView;
    }

    public static class ViewHolder {
        TextView text;
        ImageView is_select;
    }
}
